package cn.edu.zut.internship.web.controller.notify;

import cn.edu.zut.internship.bean.sys.Result;
import cn.edu.zut.internship.bean.sys.SysUser;
import cn.edu.zut.internship.iservice.notify.NoticeSV;
import cn.edu.zut.internship.web.utils.UserInfoUtil;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/notice")
public class noticeController {
    @Reference
    NoticeSV noticeSV;
    /**
     * 获取所有通知
     * @return
     */
    @RequestMapping("/getNoticeList")
    public Result getNoticeList(@RequestBody Map paarams){
        Result result = new Result();
        result = noticeSV.getNoticeList(paarams);
        return result;
    }

    /**
     * 新建通知
     * @param paarams
     * @return
     */
    @RequestMapping("/addNotice")
    public Result addNotice(@RequestBody Map paarams){
        Result result = new Result();
        SysUser userInfo = UserInfoUtil.getUserInfo();
        paarams.put("creatAccount",userInfo.getUserAccount());
        result = noticeSV.addNotice(paarams);
        return result;
    }

    /**
     * 查看通知详情
     * @param paarams
     * @return
     */
    @RequestMapping("/getNotice")
    public Result getNotice(@RequestBody Map paarams){
        Result result = new Result();
        result = noticeSV.getNotice(paarams);
        return result;
    }

    /**
     * 删除通知
     * @param paarams
     * @return
     */
    @RequestMapping("/deleteNotice")
    public Result deleteNotice(@RequestBody Map paarams){
        Result result = new Result();
        result = noticeSV.deleteNotice(paarams);
        return result;
    }

    /**
     * 修改通知
     * @param paarams
     * @return
     */
    @RequestMapping("/updateNotice")
    public Result updateNotice(@RequestBody Map paarams){
        Result result = new Result();
        SysUser userInfo = UserInfoUtil.getUserInfo();
        paarams.put("updateAccount",userInfo.getUserAccount());
        result = noticeSV.updateNotice(paarams);
        return result;
    }

    /**
     * 获取我的通知列表
     * @param paarams
     * @return
     */
    @RequestMapping("/getMyNoticeList")
    public Result getMyNoticeList(@RequestBody Map paarams){
        Result result = new Result();
        SysUser userInfo = UserInfoUtil.getUserInfo();
        paarams.put("userType",userInfo.getUserType());
        result = noticeSV.getMyNoticeList(paarams);
        return result;
    }
}
